Complete Guide with Descriptions & Examples
So, you're no longer intimidated by the terminal. You've used ls
, cd
, and sudo
without breaking your system. That’s awesome—but now it’s time to go deeper.
In this post, we'll explore advanced Linux commands, explain what they do, why they matter, and give you real-life examples. Whether you're managing servers, developing software, or automating tasks, these commands will help you work more efficiently and effectively.
🔍 1. grep
– Search Text in Files
📘 Description:
grep
stands for Global Regular Expression Print. It's used to search for specific text patterns inside files.
🧪 Example:
Search for the word "error" in a log file:
Make it case-insensitive:
Search recursively in all files in a folder:
🧮 2. awk
– Advanced Text Processing
📘 Description:
awk
is a programming language for working with structured text, especially columns in files.
🧪 Example:
Print the first column of a file:
Print the second column only if the third column contains the word "fail":
🧹 3. sed
– Stream Editor
📘 Description:
sed
is used for text manipulation, such as find-and-replace, deleting lines, or inserting text.
🧪 Example:
Replace all "apple" with "orange" in a file:
Delete all blank lines:
Insert a line after every line containing "Name":
🔁 4. xargs
– Build and Execute Command Lines
📘 Description:
xargs
reads items from input and builds command lines to run on them. Great for pairing with find
or grep
.
🧪 Example:
Delete all .tmp
files:
Run md5sum
on all .txt
files:
🕒 5. cron
– Schedule Tasks
📘 Description:
cron
is used to schedule scripts or commands to run at specific times or intervals.
🧪 Example:
Open your crontab:
Add a job to run a backup every day at 2 AM:
Explanation:
-
0 2
→ 2:00 AM -
* * *
→ every day, every month, every weekday
🔎 6. find
– Search for Files and Directories
📘 Description:
find
lets you search for files and folders based on name, type, size, modified time, and more.
🧪 Example:
Find all .log
files in /var
:
Delete all .tmp
files:
Find files larger than 100MB:
🧰 7. rsync
– Sync and Backup Files
📘 Description:
rsync
is used to copy files and folders efficiently, syncing only changes between source and destination.
🧪 Example:
Sync a folder to a backup drive:
Sync files to a remote server:
Flags used:
-
-a
: archive mode -
-v
: verbose -
-h
: human-readable -
-z
: compress files during transfer
⚙️ 8. chmod
– Change File Permissions
📘 Description:
chmod
changes who can read, write, or execute a file.
🧪 Example:
Give the owner full rights, and others read and execute:
Explanation:
-
7
: read (4) + write (2) + execute (1) -
5
: read (4) + execute (1)
Make a file executable:
👤 9. chown
– Change File Ownership
📘 Description:
chown
changes the user and/or group that owns a file.
🧪 Example:
Make deepak
the owner of a file:
Change owner and group:
🧪 10. top
and htop
– Monitor System Processes
📘 Description:
-
top
shows live system resource usage (CPU, RAM, running processes). -
htop
is an enhanced, color-coded version (must be installed).
🧪 Example:
Start top
:
Press q
to quit.
Install and run htop
:
Press F9
in htop
to kill a process directly.
📦 11. tar
– Compress and Archive Files
📘 Description:
tar
is used to archive multiple files or directories into one .tar
, .tar.gz
, or .tgz
file.
🧪 Example:
Create a compressed archive:
Extract it:
Flags:
-
c
: create -
z
: compress with gzip -
v
: verbose (show progress) -
f
: file name
📂 12. Shell Scripting – Automate Like a Pro
📘 Description:
Shell scripts let you automate repetitive tasks by writing commands in a .sh
file.
🧪 Example:
Save it as backup.sh
, then run:
🧙 Bonus Tip: Combine Commands with Pipes and Logic
What it does:
-
Searches for "ERROR" in
app.log
-
Retrieve the second word (could be IP, module, etc.)
-
Sorts and counts unique occurrences
-
Sorts them by frequency
That’s real power—building tools on the fly using simple commands.
🏁 Final Thoughts
Linux is not just an operating system—it’s a toolkit. These advanced commands unlock the full potential of your system and give you the power to automate, optimize, and dominate your workflows.
Start with the examples in this guide, and experiment. The more you use these tools, the more second-nature they become.